


//
//  ZYStudentDetailTowCell.m
//  优学荟管理系统
//
//  Created by Ethan on 2017/10/7.
//  Copyright © 2017年 星道三好. All rights reserved.
//

#import "ZYStudentDetailTowCell.h"
#import "ZYStudentDetailTowModel.h"
@implementation ZYStudentDetailTowCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setUpSuperView];
    }
    
    return self;
    
}

- (void)assignByZYStudentDetailTowModel:(ZYStudentDetailTowModel *)model{
    
    
    

    
    NSMutableAttributedString *hintString=[[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"学生姓名  %@",[model.owner valueForKey:@"petName"]]];
    //获取要调整颜色的文字位置,调整颜色
    NSRange range1=[[hintString string]rangeOfString:@"学生姓名"];
    [hintString addAttribute:NSForegroundColorAttributeName value:ColorRGB(153,153,153) range:range1];
    
    self.studentName.attributedText=hintString;
    
    
    
    
    
    
    
   
    NSMutableAttributedString *hintStringTow =[[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"家长电话  %@",[model.owner valueForKey:@"phone"]]];
    //获取要调整颜色的文字位置,调整颜色
    NSRange rangeTow=[[hintStringTow string]rangeOfString:@"家长电话"];
    [hintStringTow addAttribute:NSForegroundColorAttributeName value:ColorRGB(153,153,153) range:rangeTow];
    
    self.phoneNumber.attributedText=hintStringTow;
    
    
    
    
    
    
    
    BOOL isUp = [NSString isBlankString:model.enrollTime];
    
    
    if (isUp) {
        
        self.timeLabel.text = @"缴费时间  ";
        self.timeLabel.textColor = ColorRGB(153, 153, 153);
    }else{
        
        
        // self.timeLabel.text = [NSString stringWithFormat:@"%@",model.enrollTime];
        
        NSMutableAttributedString *hintStringThree =[[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"缴费时间  %@",model.enrollTime]];
        //获取要调整颜色的文字位置,调整颜色
        NSRange rangeThree=[[hintStringThree string]rangeOfString:@"缴费时间"];
        [hintStringThree addAttribute:NSForegroundColorAttributeName value:ColorRGB(153,153,153) range:rangeThree];
        
        self.timeLabel.attributedText=hintStringThree;
        
    }
    
    
    
    
    BOOL isUpTow  = [NSString isBlankString:[model.trainLesson valueForKey:@"name"]];
    
    
    if (isUpTow) {
        
        
        self.payLabel.text = @"课程名称";
        self.payLabel.textColor = ColorRGB(153, 153, 153);
        
        
        
    }else{
        
        
        
        NSMutableAttributedString *hintStringFour =[[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"课程名称  %@",[model.trainLesson valueForKey:@"name"]]];
        //获取要调整颜色的文字位置,调整颜色
        NSRange rangeFour=[[hintStringFour string]rangeOfString:@"课程名称"];
        [hintStringFour addAttribute:NSForegroundColorAttributeName value:ColorRGB(153,153,153) range:rangeFour];
        
        self.payLabel.attributedText=hintStringFour;
        
        
    }
    
    
    
    
    
    
    
}


- (void)setUpSuperView{
    
    
    self.studentName = [UILabel new];
    //    self.studentName.backgroundColor= [UIColor redColor];
    self.studentName.font = [UIFont systemFontOfSize:14];
    self.studentName.textAlignment = NSTextAlignmentCenter;
    self.studentName.textColor = ColorRGB(0, 0, 0);
    [self.contentView addSubview:self.studentName];
    
    
    self.phoneNumber = [UILabel new];
    //    self.phoneNumber.backgroundColor= [UIColor purpleColor];
    self.phoneNumber.font = [UIFont systemFontOfSize:14];
    self.phoneNumber.textAlignment = NSTextAlignmentCenter;
    self.phoneNumber.textColor = ColorRGB(0, 0, 0);
    [self.contentView addSubview:self.phoneNumber];
    
    
    self.payLabel = [UILabel new];
    //self.payLabel.backgroundColor= [UIColor greenColor];
    self.payLabel.font = [UIFont systemFontOfSize:14];
    self.payLabel.numberOfLines= 0;
    self.payLabel.textColor = ColorRGB(0, 0, 0);
    self.payLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.payLabel];
    
    
    
    self.timeLabel = [UILabel new];
    // self.timeLabel.backgroundColor= [UIColor redColor];
    self.timeLabel.font = [UIFont systemFontOfSize:14];
    self.timeLabel.textAlignment = NSTextAlignmentCenter;
    self.timeLabel.textColor = ColorRGB(0, 0, 0);
    [self.contentView addSubview:self.timeLabel];
    
    
    self.phoneButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    [self.phoneButton setImage:[UIImage imageNamed:@"icon_phone_default"] forState:(UIControlStateNormal)];
    [self.contentView addSubview:self.phoneButton];
    
    
    self.studentName.text = @"课程名称 ";
    [self.studentName mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.offset(15);
        make.top.offset(10);
    }];
    
    UILabel *grayLabel = [UILabel new];
    grayLabel.backgroundColor = ColorRGB(247, 245, 245);
    [self.contentView addSubview:grayLabel];
    
    [grayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(0);
        make.top.equalTo(self.studentName.mas_bottom).offset(10);
        make.width.offset(kScreenWidth);
        make.height.offset(1);
    }];
    
    
    
    self.payLabel.text = @"课程名称";
    [self.payLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.studentName);
        make.top.equalTo(grayLabel.mas_bottom).offset(10);
    }];
    
    
    UILabel *grayLabelTow = [UILabel new];
    grayLabelTow.backgroundColor = ColorRGB(247, 245, 245);
    [self.contentView addSubview:grayLabelTow];
    
    [grayLabelTow mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(0);
        make.top.equalTo(self.payLabel.mas_bottom).offset(10);
        make.width.offset(kScreenWidth);
        make.height.offset(1);
    }];
    
    
    self.timeLabel.text = @"2012.222";
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.payLabel);
        make.top.equalTo(grayLabelTow.mas_bottom).offset(10);
    }];
    
    
    
    
    UILabel *grayLabelThree = [UILabel new];
    grayLabelThree.backgroundColor = ColorRGB(247, 245, 245);
    [self.contentView addSubview:grayLabelThree];
    
    [grayLabelThree mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(0);
        make.top.equalTo(self.timeLabel.mas_bottom).offset(10);
        make.width.offset(kScreenWidth);
        make.height.offset(1);
    }];
    
    
    
    self.phoneNumber.text = @"15738611537";
    [self.phoneNumber mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.timeLabel);
        make.top.equalTo(grayLabelThree.mas_bottom).offset(10);
    }];
    
    
    
    [self.phoneButton mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.equalTo(self).offset(-15);
        make.top.centerY.equalTo(self.phoneNumber);
        
    }];
    
    
    
    
    
    
    UILabel *grayLabelFour = [UILabel new];
    grayLabelFour.backgroundColor = ColorRGB(247, 245, 245);
    [self.contentView addSubview:grayLabelFour];
    
    [grayLabelFour mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(0);
        make.top.equalTo(self.phoneNumber.mas_bottom).offset(10);
        make.width.offset(kScreenWidth);
        make.height.offset(10);
    }];
    
    
    [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.offset(0);
        make.bottom.mas_equalTo(grayLabelFour).offset(0);
        
    }];
    
    
    
    
}































@end
